package cn.jsj.dispose;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jsj.object.FrontPracLawyer;
import cn.jsj.pojo.TblPracticeLawyer;
import cn.jsj.temporary.data.TemporaryData;
import cn.jsj.utils.ProduceJsonData;
import cn.jsj.utils.SysLogger;
/**
 * 加载所有实习律师信息处理类
 * @author LI
 *
 */
public class PracLawyerInfoRequest extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//调试信息
		cn.jsj.utils.SysLogger.PrintInfo("请求查看实习律师详细信息！！！");
		
		//获得参数：1.第几条开始。2.一页显示几条
		int startNumb=Integer.parseInt(request.getParameter("start"));
		int totalNumb=Integer.parseInt(request.getParameter("limit"));
		
		//调试信息
		cn.jsj.utils.SysLogger.PrintInfo("start---->"+startNumb+"   total--------->"+totalNumb);
		
		//获得总共实习律师信息条数
		cn.jsj.dao.TblPracticeLawyerDAO tpld=new cn.jsj.dao.TblPracticeLawyerDAO();
		int pracLawyerNumber=tpld.getPracLawyerInfoNumb();
		
		//调试信息
		cn.jsj.utils.SysLogger.PrintInfo("实习律师信息条数----->"+pracLawyerNumber);
		
		//暂存实习律师信息队列
		java.util.List<TblPracticeLawyer> pracLawyerInfo=new java.util.LinkedList<TblPracticeLawyer>();
		
		//获取这个页面要显示的实习律师信息
		pracLawyerInfo=tpld.getThePracLawyerInfo(startNumb, totalNumb);
		
		//调试信息
		SysLogger.PrintInfo(pracLawyerInfo.size());
		
		//前台实习律师信息对象队列
		java.util.List<FrontPracLawyer> frontLawyerInfo=new java.util.LinkedList<FrontPracLawyer>();
		//改造成前台需要的律师信息对象
		cn.jsj.object.rebuild.PracLawyerInfoRebuild plir=new cn.jsj.object.rebuild.PracLawyerInfoRebuild();
		for(int i=0;i<pracLawyerInfo.size();i++){
			cn.jsj.object.FrontPracLawyer fpl=plir.rebuildPracLawyer(pracLawyerInfo.get(i));
			frontLawyerInfo.add(fpl);
		}
			//改造成JSON型数据
			ProduceJsonData pjd=new ProduceJsonData();
		String resultData=	pjd.jsonFromList(frontLawyerInfo,pracLawyerNumber);
			
		//调试信息
		SysLogger.PrintInfo(resultData);
		//输出到客户端
		java.io.PrintWriter pw=response.getWriter();
		pw.println(resultData);
		pw.flush();
		

		
		
		 
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request,response);
	}

}
